﻿@using Eqwww.Code

@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_ManageIndexLayout.cshtml";
}

<div id="eq-operate">
    <div class="mdui-appbar mdui-appbar-fixed mdui-color-white mdui-shadow-1">
        <div class="mdui-toolbar">
            <a class="eq-operate-cancel-select" href="javascript:;" mdui-tooltip="{content: '取消选择'}">
                已选中 <b>1</b> 项
            </a>

            <module-buttons class="mdui-btn-group mdui-hidden-sm-down" buttons="@ViewBag.SelectedButtons"></module-buttons>

            <module-buttons class="mdui-hidden-md-up" buttons="@ViewBag.SelectedButtons" is-float="true"></module-buttons>

            <div class="mdui-toolbar-spacer"></div>
            <a class="eq-operate-cancel-select mdui-btn mdui-ripple" href="javascript:;">
                <i class="mdui-icon material-icons">do_not_disturb</i> 取消
            </a>
        </div>
    </div>
</div>
<div class="mdui-appbar mdui-shadow-1 mdui-color-white" id="xd-appbar">
    <div class="mdui-toolbar">
        <div class="mdui-btn-group">
            <a id="refreshBtn" class="eq-operate-cancel-select mdui-btn mdui-text-color-theme mdui-ripple mdui-ripple-black" href="javascript:;">
                <i class="mdui-icon material-icons">refresh</i> 刷新
            </a>
            <a id="ShaiXuan" class="mdui-btn mdui-ripple mdui-text-color-theme mdui-ripple-black" href="javascript:;">
                <i class="mdui-icon material-icons">keyboard_arrow_down</i> 筛选
            </a>
            <a id="reloadBtn" class="mdui-btn mdui-ripple mdui-text-color-theme mdui-ripple-black" href="javascript:;">
                <i class="mdui-icon material-icons">autorenew</i> 重置
            </a>
        </div>

        <div class="mdui-toolbar-spacer"></div>


        <module-buttons class="mdui-btn-group" buttons="@ViewBag.InitialButtons"></module-buttons>


    </div>
</div>

<div class="mdui-dialog" id="ShaiXuanBox">
    <div class="mdui-container mdui-color-white">
        <div class="mdui-row ">
            <div class="mdui-col-xs-12">
                <div class="mdui-textfield">
                    <label class="mdui-textfield-label">工种名称关键字</label>
                    <input type="text" class="mdui-textfield-input" name="keyword" id="keyword" />
                </div>
            </div>

        </div>
        <div class="mdui-dialog-actions">
            <button class="mdui-btn mdui-text-color-theme mdui-ripple" id="searchBtn"><i class="mdui-icon material-icons">check</i> 确认</button>
            <button class="mdui-btn  mdui-ripple" mdui-dialog-cancel><i class="mdui-icon material-icons">close</i> 取消</button>
        </div>
    </div>
</div>

<div class="mdui-container-fluid mdui-m-t-1">
    <div class="mdui-table-fluid">
        <table class="mdui-table" id="gridTable"></table>
        <div id="gridPager"></div>
    </div>
</div>


@section Scripts{
    <script>
        var inst = new mdui.Dialog($('#ShaiXuanBox'));
        $(function () {
            gridTable();
            $('#ShaiXuan').click(function () {
                inst.open();
            })
        });

        function gridTable() {
            var $gridList = $("#gridTable");
            $gridList.dataGrid({
                url: '/SystemManage/Job/IndexGridJson',
                mtype: "GET",
                datatype: "json",
                sortname: 'CreateTime',
                sortorder: 'DESC',
                colModel: [
                    { label: 'Id', name: 'Id', key: true, hidden: true },
                    { label: '名称', name: 'Name', width: 150, sortable:false },
                    { label: '编码', name: 'Code', width: 100, sortable: false },
                    { label: '排序码', name: 'SortCode', width: 100, sortable: false },
                    {
                        label: '创建时间', name: 'CreateTime', width: 110, formatter: 'date', formatoptions: {
                            srcformat: 'Y-m-d', newformat: 'Y-m-d'
                        }
                    }

                ],
                viewrecords: true,
                height: getGridHeight() - 36,
                rowNum: 20,
                pager: "#gridPager",
                shrinkToFit: true
            });


            $('#refreshBtn').click(function () {
                window.location.reload();
            });

            $('#searchBtn').click(function () {
                $gridList.jqGrid('setGridParam', {
                    postData: {
                        keyword: $('#keyword').val()
                    },
                }).trigger('reloadGrid');
                inst.close();
            });

            $('#reloadBtn').click(function () {
                $('#keyword').val('');
                $gridList.jqGrid('setGridParam', {
                    postData: {
                        keyword: $('#keyword').val()
                    },
                }).trigger('reloadGrid');
            })
        }

        function btn_create() {

            $.modalOpen({
                id: 'formCreate',
                title: '新建',
                url: '/SystemManage/Job/Create',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
            return false;
        }

        function btn_edit() {
            var key = $('#gridTable').jqGridRowValue().Id;
            if (!key) {
                top.$.errorLayer('未选中任何行！');
                return false;
            }

            $.modalOpen({
                id: 'formEditButton',
                title: '修改',
                url: '/SystemManage/Job/Edit?id=' + key,
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }

        function btn_details() {
            var key = $('#gridTable').jqGridRowValue().Id;
            if (!key) {
                top.$.errorLayer('未选中任何行！');
                return false;
            }
            $.modalOpen({
                id: 'Details',
                title: '查看',
                url: '/SystemManage/Job/Details?id=' + key,
                width: '100%',
                height: '100%',
                isback: true,
                hideConfirmBtn: true,
                btn: null
            });
        }

        function btn_delete() {
            var key = $('#gridTable').jqGridRowValue().Id;
            if (!key) {
                top.$.errorLayer('未选中任何行！');
                return false;
            }

            $.deleteForm({
                url: '/SystemManage/Job/Delete',
                param: { id: key },
                success: function () {
                    window.location.reload();
                }
            })
        }

    </script>
}
